#pragma once

#include <gofcl_spi_r.h>

typedef struct {
	u16_s CKPH : 1;
	u16_s CKPL : 1;
	u16_s MSTMOD : 1;
	u16_s PSC : 3;
	u16_s SPIEN : 1;
	u16_s LF : 1;
	u16_s SWNSS : 1;
	u16_s SWNSSEN : 1;
	u16_s RO : 1;
	u16_s FF16 : 1;
	u16_s CRCNT : 1;
	u16_s CRCEN : 1;
	u16_s BDOEN : 1;
	u16_s BDEN : 1;
} spi_ctl0_s;

_Static_assert(sizeof(spi_ctl0_s) == 2, "Struct spi_ctl0_s defined error!");

static inline void spi_wreg_ctl0_s(spi_qe spi_q, spi_ctl0_s ctl0) {
	union {
		spi_ctl0_s c;
		u32_s u;
	} cu = {
		.c = ctl0,
	};
	spi_wreg(spi_q, SPI_CTL0_R, cu.u);
}
